# 显示时的放大倍率,因为按照题目大小单位，1像素的小车根本看不到,必须放大
up_sample = 5
# 点之间的间隔
distance = 20 * up_sample

# 点的半径
radius = 1 * up_sample

# 图像大小
width = 200 * up_sample
height = 200 * up_sample

# 坐标系以多少厘米为单位
gird_size = 1 * up_sample

yaml = '---\n'
# 图像大小
yaml += 'RECT_OBSTACLES:\n  0:\n  - [0, 0]\n' + f'  - [{width - 1}, {height - 1}]\n'
# 每一个网格大小
yaml += f'GRID_SIZE: {gird_size}\n'
# 每个agent半径
yaml += f'ROBOT_RADIUS: {radius}\n'

# 起始点坐标
yaml += 'START:\n'

start_points = [[30, 30], [50, 30], [70, 30], [90, 30], [110, 30], [130, 30], [150, 30], [170, 30],
                [30, 50], [50, 50], [70, 50], [90, 50], [110, 50], [130, 50], [150, 50],
                [30, 70], [50, 70], [70, 70], [90, 70], [110, 70], [130, 70],
                [30, 90], [50, 90], [70, 90], [90, 90], [110, 90],
                [30, 110], [50, 110], [70, 110], [90, 110],
                [30, 130], [50, 130], [70, 130],
                [30, 150], [50, 150],
                [30, 170]]
for point in start_points:
    point = [point[0] * 5, height - point[1] * 5]
    yaml += '- !!python/tuple ' + str(point) + '\n'

# 目标点坐标生成
yaml += 'GOAL:\n'

# 目标点坐标
goal_points = [[10, 2], [9, 3], [8, 4], [7, 5], [6, 6], [5, 7], [4, 8], [3, 9], [2, 10], [1, 11], [1, 12.4],
               [1.6, 14], [2.5, 15.4], [3.3, 16.6], [4.7, 17.5], [6, 18], [7.3, 17.5], [8.6, 16.9], [10, 16],
               [11, 3], [12, 4], [13, 5], [14, 6], [15, 7], [16, 8], [17, 9], [18, 10], [19, 11], [19, 12.4],
               [18.4, 14], [17.5, 15.4], [16.7, 16.6], [15.3, 17.5], [14, 18], [12.7, 17.5], [11.4, 16.9]]
for point in goal_points:
    point = [int(point[0] * 50), int(height - point[1] * 50)]
    yaml += '- !!python/tuple ' + str(point) + '\n'

# 写入
with open('question1.yaml', mode='w') as f:
    f.write(yaml)
